﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GenerateColumn
{
    public partial class Main : Form
    {
        private int ColCount = 1;
        private int lbl_y = 24;
        private int txt_y = 21;
        public Main()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.CreateControl();
        }

        private void CreateControl()
        {
            this.ColCount += 1;
            // 表名lable
            Label lbl_bm = new Label();
            lbl_bm.AutoSize = true;
            lbl_bm.Location = new Point(19,this.ColCount * this.lbl_y);
            lbl_bm.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
            lbl_bm.Name = "lbl_bm" + this.ColCount;
            lbl_bm.TabIndex = 0;
            lbl_bm.Text = "表名：";

            // 列名lable
            Label lbl_lm = new Label();
            lbl_lm.AutoSize = true;
            lbl_lm.Location = new Point(135, this.ColCount * this.lbl_y);
            lbl_lm.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
            lbl_lm.Name = "lbl_lm" + this.ColCount;
            lbl_lm.TabIndex = 0;
            lbl_lm.Text = "列名：";

            // 类型lable
            Label lbl_lx = new Label();
            lbl_lx.AutoSize = true;
            lbl_lx.Location = new Point(260, this.ColCount * this.lbl_y);
            lbl_lx.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
            lbl_lx.Name = "lbl_lx" + this.ColCount;
            lbl_lx.TabIndex = 0;
            lbl_lx.Text = "类型：";

            // 默认值lable
            Label lbl_mrz = new Label();
            lbl_mrz.AutoSize = true;
            lbl_mrz.Location = new Point(396, this.ColCount * this.lbl_y);
            lbl_mrz.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
            lbl_mrz.Name = "lbl_mrz" + this.ColCount;
            lbl_mrz.TabIndex = 0;
            lbl_mrz.Text = "默认值：";

            this.panel1.Controls.Add(lbl_bm);
            this.panel1.Controls.Add(lbl_lm);
            this.panel1.Controls.Add(lbl_lx);
            this.panel1.Controls.Add(lbl_mrz);

            TextBox txt_bm = new TextBox();
            txt_bm.Location = new System.Drawing.Point(180, this.ColCount * this.txt_y);
            txt_bm.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
            txt_bm.Name = "txt_bm" + this.ColCount;
            txt_bm.Size = new System.Drawing.Size(68, 21);
            txt_bm.TabIndex = 1 + this.ColCount;

            TextBox txt_lm = new TextBox();
            txt_lm.Location = new System.Drawing.Point(64, this.ColCount * this.txt_y);
            txt_lm.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
            txt_lm.Name = "txt_lm" + this.ColCount;
            txt_lm.Size = new System.Drawing.Size(68, 21);
            txt_lm.TabIndex = 2 + this.ColCount;

            ComboBox cmb_lx = new ComboBox();
            cmb_lx.FormattingEnabled = true;
            cmb_lx.Items.AddRange(new object[] {
                "varchar(50)",
                "varchar(32)",
                "int",
                "float",
                "decimal(18, 0)"});
            cmb_lx.Location = new System.Drawing.Point(305, this.ColCount * this.txt_y);
            cmb_lx.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
            cmb_lx.Name = "cmb_lx" + this.ColCount;
            cmb_lx.Size = new System.Drawing.Size(82, 21);
            cmb_lx.TabIndex = 3 + this.ColCount;


            TextBox txt_mrz = new TextBox();
            txt_mrz.Location = new System.Drawing.Point(453, this.ColCount * this.txt_y);
            txt_mrz.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
            txt_mrz.Name = "txt_mrz" + this.ColCount;
            txt_mrz.Size = new System.Drawing.Size(68, 21);
            txt_mrz.TabIndex = 4 + this.ColCount;

            this.panel1.Controls.Add(txt_bm);
            this.panel1.Controls.Add(txt_lm);
            this.panel1.Controls.Add(cmb_lx);
            this.panel1.Controls.Add(txt_mrz);

        }

    }
}
